package com.sh.设计模式.策略模式以及优化.map注册;

import java.util.HashMap;
import java.util.Map;

public class StrategyRegistry {
    private static final Map<String, DiscountStrategy> strategyMap = new HashMap<>();

    static {
        strategyMap.put("normal", price -> price);
        strategyMap.put("member", price -> price * 0.9);
        strategyMap.put("vip", price -> price * 0.8);
    }

    public static DiscountStrategy getStrategy(String userType) {
        return strategyMap.getOrDefault(userType, price -> price);
    }
}
